home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
PIL
/
ImageDraw2.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
5KB
|
127 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import Image
import ImageColor
import ImageDraw
import ImageFont
import ImagePath
class Pen:
def __init__(self, color, width = 1, opacity = 255):
self.color = ImageColor.getrgb(color)
self.width = width
class Brush:
def __init__(self, color, opacity = 255):
self.color = ImageColor.getrgb(color)
class Font:
def __init__(self, color, file, size = 12):
self.color = ImageColor.getrgb(color)
self.font = ImageFont.truetype(file, size)
class Draw:
def __init__(self, image, size = None, color = None):
if not hasattr(image, 'im'):
image = Image.new(image, size, color)
self.draw = ImageDraw.Draw(image)
self.image = image
self.transform = None
def flush(self):
return self.image
def render(self, op, xy, pen, brush = None):
outline = None
fill = None
width = 1
if isinstance(pen, Pen):
outline = pen.color
width = pen.width
elif isinstance(brush, Pen):
outline = brush.color
width = brush.width
if isinstance(brush, Brush):
fill = brush.color
elif isinstance(pen, Brush):
fill = pen.color
if self.transform:
xy = ImagePath.Path(xy)
xy.transform(self.transform)
if op == 'line':
self.draw.line(xy, fill = outline, width = width)
else:
getattr(self.draw, op)(xy, fill = fill, outline = outline)
def settransform(self, .1):
(xoffset, yoffset) = .1
self.transform = (1, 0, xoffset, 0, 1, yoffset)
def arc(self, xy, start, end, *options):
self.render('arc', xy, start, end, *options)
def chord(self, xy, start, end, *options):
self.render('chord', xy, start, end, *options)
def ellipse(self, xy, *options):
self.render('ellipse', xy, *options)
def pieslice(self, xy, start, end, *options):
self.render('pieslice', xy, start, end, *options)
def line(self, xy, *options):
self.render('line', xy, *options)
def rectangle(self, xy, *options):
self.render('rectangle', xy, *options)
def ellipse(self, xy, *options):
self.render('ellipse', xy, *options)
def polygon(self, xy, *options):
self.render('polygon', xy, *options)
def symbol(self, xy, symbol, *options):
raise NotImplementedError('not in this version')
def text(self, xy, text, font):
if self.transform:
xy = ImagePath.Path(xy)
xy.transform(self.transform)
self.draw.text(xy, text, font = font.font, fill = font.color)
def textsize(self, text, font):
return self.draw.textsize(text, font = font.font)